package com.ld.poetry.aigc.iflycode.gclu.codegenerate;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class SecurityController {

    @Autowired
    private SecurityService securityService;

    // 增加org.example.dto.Security以及按securityID修改，查找和删除的接口

    @PostMapping("/security")
    public Security addSecurity(@RequestBody Security security) {
        return securityService.addSecurity(security);
    }

    @PutMapping("/security/{id}")
    public Security updateSecurity(@PathVariable Long id, @RequestBody Security security) {
        return securityService.updateSecurity(id, security);
    }

    @GetMapping("/security/{id}")
    public Security getSecurity(@PathVariable Long id) {
        return securityService.getSecurity(id);
    }

    @DeleteMapping("/security/{id}")
    public void deleteSecurity(@PathVariable Long id) {
        securityService.deleteSecurity(id);
    }

    // 生成查询org.example.dto.Security类tradingPrice最高的所有证券的接口，返回所有证券

    @GetMapping("/top-securities")
    public List<Security> getTopSecurities() {
        return securityService.getTopSecurities();
    }
}